home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
libgutil
/
getset.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
113 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* getset -
* Get and set values stored in ~/.gamma
*
* Paul Haeberli - 1984
*
*/
#include "stdio.h"
#include "port.h"
#include "gl.h"
FILE *configopen();
float getgamma()
{
FILE *gamfile;
float gam;
if ((gamfile = configopen(".gamma","r")) ) {
if (fscanf(gamfile,"%f\n",&gam) == 1) {
fclose(gamfile);
return gam;
} else
fclose(gamfile);
}
return 2.2;
}
setgamma( gam )
float gam;
{
FILE *gamfile;
if ((gamfile = configopen(".gamma","w")) == 0) {
fprintf(stderr,"couldn't open .gamma\n");
return;
}
fprintf(gamfile,"%f\n",gam);
fclose(gamfile);
newgamtables();
}
getcolorbal(r,g,b)
unsigned int *r, *g, *b;
{
FILE *cbfile;
if ((cbfile = configopen(".cbal","r")) ) {
if (fscanf(cbfile,"%d %d %d\n",r,g,b) == 3) {
if (*r>255)
*r = 255;
if (*g>255)
*g = 255;
if (*b>255)
*b = 255;
fclose(cbfile);
return;
} else
fclose(cbfile);
}
*r = 255;
*g = 255;
*b = 255;
return;
}
setcolorbal(r,g,b)
int r, g, b;
{
FILE *cbfile;
if ((cbfile = configopen(".cbal","w")) == 0) {
fprintf(stderr,"couldn't open .cbal\n");
return;
}
fprintf(cbfile,"%d %d %d\n",r,g,b);
fclose(cbfile);
newgamtables();
}
FILE *configopen( name, mode )
char name[];
char mode[];
{
char homepath[100];
FILE *f;
char *cptr;
cptr = (char *)getenv("HOME");
if (!cptr)
return 0;
strcpy(homepath,cptr);
strcat(homepath,"/");
strcat(homepath,name);
return fopen(homepath,mode);
}